package com.lc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lc.exception.BusinessException;
import com.lc.mapper.PPCMapper;
import com.lc.pojo.PmsProductCategory;
import com.lc.result.ResultEnum;
import com.lc.service.PPCService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PPCServiceImpl extends ServiceImpl<PPCMapper, PmsProductCategory> implements PPCService {

    @Resource
    private PPCMapper ppcMapper;

    @Override
    @Cacheable(value = "PPCList" , key = "'PPCList'")
    public List<PmsProductCategory> getClassifyPPC() {
        System.out.println("==========穿过缓存===========");
        List<PmsProductCategory> list = ppcMapper.getClassifyPPC();
        if(list == null ){
            throw new BusinessException(ResultEnum.COMMON_EXCEPTION);
        }
        return list;
    }
}
